/*
 * @Author: tkp
 * @Date: 2021-11-28 19:44:20
 */
// 自定义指令的注册
import Vue from 'vue'
import router from '@/router'
Vue.directive('hasRole', {
    inserted(el, binding) {
        let isState = binding.value.isState || false
        if (router.currentRoute.meta.permission.length > 0) {
            let data = router.currentRoute.meta.permission.filter(item => binding.value.frontRoute == item.frontRoute)
            if (data.length === 0) {
                if (isState) {
                    el.disabled = true
                    el.classList.add('is-disabled')
                } else {
                    el.disabled = true
                    el.classList.add('is-disabled')
                    el.parentNode.removeChild(el)
                }
            }
        } else {
            el.disabled = true
            el.classList.add('is-disabled')
            el.parentNode.removeChild(el)

        }
    }
})

